<template>
	<!-- 退货采购 -->
	<view>
		<view class="titlebox">
			<text class="text">请求详情</text>
			<image @click="chang()" v-show="show" class="img1" src="../../../static/paimg/修改.png" mode=""></image>
			<image @click="delect()" v-show="show" class="img2" src="../../../static/paimg/删除.png" mode=""></image>
		</view>
		<view class="boxcent">
			<view class="box1">
				<text class="text">记录编号</text>
				<text class="text1">{{list.id}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">日期</text>
				<text class="text1">{{time}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">商品名称</text>
				<text class="text1">{{list.stoname}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">规格</text>
				<text class="text1">{{list.stospe}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">数量</text>
				<text class="text1">{{list.num}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">入库价</text>
				<text class="text1">{{list.purchase_price}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">总金额</text>
				<text class="text1">{{list.amount}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">供应商</text>
				<text class="text1">{{list.supname}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">目标仓库</text>
				<text class="text1">{{list.wname}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">发起人</text>
				<text class="text1">{{list.whentryname}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">完成状态</text>
				<text class="text1">{{list.whether}}</text>
			</view>
			<view class="br"></view>
			<view class="box1">
				<text class="text">退货原因</text>
				<text class="text1">{{list.title}}</text>
				<text v-if="list.title == undefined ">空</text>
				<text v-if="list.title == ''">空</text>
			</view>
		</view>
		<view class="btn" v-show="!show">
			<button @click="shopping">采购</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:{},show:true,time:''
			}
		},
		onLoad(option) {
			this.id = option.id;
			this.getdata();
		},
		methods: {
			async getdata(){
				const res = await this.Request({
					url:'api/retgoods/getretbyid',
					method:'POST',
					data:{id:this.id}
				})
				this.list=res.data[0]
				this.time =res.data[0].data.substring(0, 10)
			},
			chang(){
				var item = JSON.stringify(this.list);
				uni.navigateTo({
					url:'/pages/public/retgoods/changretgoods?item='+item
				})
			},
			delect(){
				var id = this.list.id;
				uni.showModal({
					title: '提示',
					content: '进行删除？',
					success: function (res) {
						if (res.confirm) {
							uni.request({
								url:'api/retgoods/delretbyid',
								method:'DELETE',
								data:{id:id},
								success: (res) => {
									if(res.data.affectedRows=1){
										uni.showToast({
											title: '删除成功'
										})
										setTimeout(() => {
											uni.reLaunch({
												url:'/pages/businessr/bus-stockup/bus-stockup'
											})
										},300)
									}
								}
							})
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.titlebox{
		margin-top: 10px;
		width: 100%;
		height: 30px;
		background-color: #efefef;
		display: flex;
		border-bottom: 1px solid #ccc;
		image{
			margin: auto 0;
			height: 20px;
			width: 20px;
		}
		.text{
			margin: 5px 0 5px 5px;
			font-size: 110%;
			font-weight: 600;
			color: #008300;
		}
		.img1{
			margin-left: 240px;
		}
		.img2{
			margin-left: 10px;
		}
	}
	.boxcent{
		margin-top: 10px;
		border-top: 2px solid #ccc;
		border-bottom: 2px solid #ccc;
		border-radius: 10px;
		.br{
			height: 1px;
			margin-left: 10%;
			background: #a5a5a5;
		}
		.box1{
			margin-top: 10px;
			margin-bottom: 10px;
			position: relative;
			width: 100%;
			.text{
				position: absolute;
				margin-left: 10%;
				font-weight: 600;
				font-size: 110%;
			}
			.text1{
				margin-left: 200px;
			}
		}
	}
	.btn{
		margin-top: 15px;
		button{
			background-color: #caffbe;
			width: 60%;
		}
	}
</style>